package com.linuxgt.pattern.adapter.scheme2;

public class ThreeAndTwoElectrcAdapter implements ThreeElectrcOutlet, TwoElectrcOutlet {

    TwoElectrcOutlet twoElectrcOutlet;
    ThreeElectrcOutlet threeElectrcOutlet;

    public ThreeAndTwoElectrcAdapter(TwoElectrcOutlet twoOutlet, ThreeElectrcOutlet threeOutlet) {
        twoElectrcOutlet = twoOutlet;
        threeElectrcOutlet = threeOutlet;
    }

    public ThreeAndTwoElectrcAdapter(ThreeElectrcOutlet threeOutlet, TwoElectrcOutlet twoOutlet) {
        twoElectrcOutlet = twoOutlet;
        threeElectrcOutlet = threeOutlet;
    }

    @Override
    public void connectElectricCurrent() {
        if (this instanceof ThreeElectrcOutlet) {
            twoElectrcOutlet.connectElectricCurrent();//TwoElectrcOutlet 是衩适配接口
        }
        if (this instanceof TwoElectrcOutlet) {
            threeElectrcOutlet.connectElectricCurrent();//ThreeElectrcOutlet 是衩适配接口
        }
    }
}
